# My pseudo code for Exercice 1
# START
#     Initialize left to 0
#     Initialize right to 0
#     Initialize sum to 0
#     FOUND<-False
#     list <- Read a list
#     target <- Read a number
#     FOR each item in list:
#         sum <- 0
#         IF item=target then:
#             FOUND=True
#             left <- item
#             right <- item
#             Display"Output:[left,right]"
#             Break
#         END IF
#         For each item* in the return part of list:
#             sum <- sum+item*
#             IF item+sum = target then:
#                 left <- item
#                 right <- item*
#                 Display"Output:[left,right]"
#                 FOUND<-True
#                 Break
#             End IF
#         END FOR
#         IF FOUND=True then:
#            Break
#         END IF
#     END FOR
#     IF FOUND=False then:
#         Display:"NOT FOUND"
#     END IF
#     Display:"The sum of elements from {left} to {right} position is {target}"
# END
            
def find_pair(arr,target):
    Found=False
    for i in range(len(arr)):
        sum=0
        if arr[i]==target:
            print(f'Output:{[i,i]}')         
            Found=True
            left=right=i
            break
        for j in range(i+1,len(arr)):
            sum+=arr[j]
            if arr[i]+sum==target:
                Found=True
                left=i
                right=j
                print(f'Output:{[i,j]}')
                break
        if Found:
            break
    if not Found:
        print("No such pair found")
    else:
        print(f'Explaination:The sum of elements from {left} to {right} position is {target}.')

find_pair([1,2,3,7,5],12)
find_pair([7,2,1],2)

        


            

